<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="basePath.jsp"%>
<!DOCTYPE html>
<html >

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商品管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="${basePath}staticjch/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${basePath}staticjch/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${basePath}staticjch/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${basePath}staticjch/css/style.css">
	<script src="${basePath}staticjch/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="${basePath}staticjch/plugins/bootstrap/js/bootstrap.min.js"></script>


	<script src="${basePath}vue/vue.js"></script>
	<script src="${basePath}vue/axios.min.js"></script>
</head>

<body class="hold-transition skin-red sidebar-mini" >
  <!-- .box-body -->
                
                    <div class="box-header with-border">
                        <h3 class="box-title">商品审核</h3>
                    </div>

                    <div class="box-body">

                        <!-- 数据表格 -->
                        <div class="table-box" id="app">

                            <!--工具栏-->
                            <div class="pull-left">
                                <div class="form-group form-inline">
                                    <div class="btn-group">
<%--                                        <button type="button" class="btn btn-default" title="删除" @click="del" ><i class="fa fa-trash-o"></i> 删除</button>--%>
<%--                                        <button type="button" class="btn btn-default" title="审核通过" ><i class="fa fa-check"></i> 审核通过</button>--%>
<%--                                        <button type="button" class="btn btn-default" title="驳回" ><i class="fa fa-ban"></i> 驳回</button>                                  --%>
<%--                                        <button type="button" class="btn btn-default" title="刷新" ><i class="fa fa-refresh"></i> 刷新</button>--%>
                                    </div>
                                </div>
                            </div>
                            <div class="box-tools pull-right">
                                <div class="has-feedback">
                                    商品名称：<input type="text" ref="goodsname">
									<button class="btn btn-default" @click="Search">查询</button>
                                </div>
                            </div>
                            <!--工具栏/-->

			                  <!--数据列表-->
			                  <table id="dataList" class="table table-bordered table-striped table-hover dataTable">

			                      <thead>
			                          <tr>
			                              <th class="" style="padding-right:0px">
			                                  <input  type="checkbox" class="icheckbox_square-blue">
			                              </th> 
										  <th class="sorting_asc">商品ID</th>
									      <th class="sorting">商品名称</th>
									      <th class="sorting">商品价格</th>
									      <th class="sorting">一级分类</th>
									      <th class="sorting">二级分类</th>
									      <th class="sorting">三级分类</th>
									      <th class="sorting">状态</th>									     						
					                      <th class="text-center">操作</th>
			                          </tr>
			                      </thead>
			                      <tbody>
<%--									 <c:forEach items="${pageInfo.list}" var="goods">--%>
			                          <tr v-for="goods in info" >
			                              <td><input type="checkbox" id="del" ></td>
<%--										  <td><input type="checkbox" id="del"  ref="del(goods.id)"></td>--%>
				                          <td>{{ goods.id}}</td>
									      <td>{{ goods.goodsName}}</td>
									      <td>{{ goods.price}}</td>
									      <td>{{ goods.category1Id}}</td>
									      <td>{{ goods.category2Id}}</td>
									      <td>{{ goods.category3Id}}</td>

		                                  <td v-if="goods.auditStatus==2">
													 未通过
		                                  </td>
										  <td v-if="goods.auditStatus==1">
											  		通过
										  </td>
										  <td v-if="goods.auditStatus==0">
											      审核中
										  </td>

		                                  <td class="text-center">                                          
		                                 	  <button type="button" class="btn bg-olive btn-xs" >详情</button>
											  <button type="button" class="btn bg-olive btn-xs" @click="del(goods.id)">删除</button>
											  <button type="button" class="btn bg-olive btn-xs" @click="success(goods.id)">审核通过</button>
											  <button type="button" class="btn bg-olive btn-xs" @click="defeat(goods.id)">驳回</button>
		                                  </td>
			                          </tr>
<%--									 </c:forEach>--%>
			                      </tbody>


							  </table>
			                  <!--数据列表/-->
							<div>
								<button   @click="indexPage" >首页</button>
								<button   @click="showPage" >上一页</button>
								<a v-for="i in pages">
									{{i}}
								</a>
								<button   @click="nextPage" >下一页</button>
								<button   @click="lastPage" >尾页</button>
							</div>
                        </div>
                        <!-- 数据表格 /-->
                        
                        
                     </div>
                    <!-- /.box-body -->
        
</body>

<script type ="text/javascript">
	//var PageNumber = 1;
	var pageNum = 1;
	//var pages = 0;
	new Vue({
		el: '#app',

		data () {
			return {
				info: null,
				pages: null
				// zking:null
			}
		},
		mounted () {
			axios
					.post('${basePath}/GoodsAudit/selectGoodsStatusAll?pageNum=1')
					.then((response)=>{
						this.info = response.data.list;
						this.pages = response.data.pages;
						//console.log(this.pages);
					}).catch(function (error) { // 请求失败处理
						console.log(error);
					});

		},
       methods:{
		   nextPage(){
			   let goodsname = this.$refs.goodsname.value
			   pageNum++;
			   axios
					   .post('${basePath}/GoodsAudit/selectGoodsStatusAll?pageNum='+pageNum+'&goodsname='+goodsname)
					   .then((response)=>{
						   this.info = response.data.list;
						   this.pages = response.data.pages;
					   })
					   .catch(function (error) { // 请求失败处理
						   console.log(error);
					   });
		   },

		   showPage(){
			   let goodsname = this.$refs.goodsname.value
			   pageNum--;
			   axios
					   .post('${basePath}/GoodsAudit/selectGoodsStatusAll?pageNum='+pageNum+'&goodsname='+goodsname)
					   .then((response)=>{
						   this.info = response.data.list;
						   this.pages = response.data.pages;
					   })
					   .catch(function (error) { // 请求失败处理
						   console.log(error);
					   });
				},

		   indexPage(){
			   let goodsname = this.$refs.goodsname.value
			   pageNum = 1;

			   axios
					   .post('${basePath}/GoodsAudit/selectGoodsStatusAll?pageNum='+pageNum+'&goodsname='+goodsname)
					   .then((response)=>{
						   this.info = response.data.list;
						   this.pages = response.data.pages;
					   })
					   .catch(function (error) { // 请求失败处理
						   console.log(error);
					   });
		   },

		lastPage(){
			let goodsname = this.$refs.goodsname.value
			pageNum = this.pages;
			axios
					.post('${basePath}/GoodsAudit/selectGoodsStatusAll?pageNum='+pageNum+'&goodsname='+goodsname)
					.then((response)=>{
						this.info = response.data.list;
						this.pages = response.data.pages;
					})
					.catch(function (error) { // 请求失败处理
						console.log(error);
					});
			},

		   Search(){
			  let goodsname = this.$refs.goodsname.value
			   axios
					   .post('${basePath}/GoodsAudit/selectGoodsStatusAll?goodsname='+goodsname)
					   .then((response)=>{
						   this.info = response.data.list;
						   this.pages = response.data.pages;
					   })
					   .catch(function (error) { // 请求失败处理
						   console.log(error);
					   });
		   		},

		   del(id){
			   let del = id
			   window.location.href="${basePath}/GoodsAudit/del?id="+del

		   },
		   success(id){
			   let success = id
			   window.location.href="${basePath}/GoodsAudit/success?id="+success
		   },
		   defeat(id){
			   let defeat = id
			   window.location.href="${basePath}/GoodsAudit/defeat?id="+defeat

		   },

	   }



	})



</script>




</html>